<?php
define('IS_DEBUG',			true );
$is_local = false;
switch($_SERVER['SERVER_ADDR']) {
	case '192.168.56.110':
		$is_local = true;
		break;
}
define('IS_LOCAL',			$is_local);

define('ROOT',				dirname(__FILE__) . '/');
define('WWWROOT',			'http://'. $_SERVER['HTTP_HOST'] . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . $_SERVER['SERVER_PORT']) . '/');

include_once ROOT . '/../ujn2/ujn.php';
ujn_runtime::setSplitAlias('adam');

$cfg						= array();
$cfg['templates_path']		= ROOT  . '/templates/';
$cfg['tmp_path']			= ROOT . '/_tmp/';
$cfg['plugins_url']			= WWWROOT . 'p_admin_plugins/';
$cfg['lefts']				= require_once ROOT . '/_tmp/left_navs.php';

ujn::runApplication($cfg, (isset($_REQUEST['cmd']) && function_exists($_REQUEST['cmd'])) ? $_REQUEST['cmd'] : 'main');


/** controllers list **/
function page_404()					{ echo '404 page'; }
function main(ujn_controller $c)	{ return $c; }
function head(ujn_controller $c)	{ return $c; }
function middle(ujn_controller $c)	{ return $c; }
function def(ujn_controller $c)		{ return $c; }
function left(ujn_controller $c) 	{
	$left = array();
	foreach(ujn::getCFG('lefts') as $path) {
		if(is_file($path . '/info.php'))
			$left[] = require_once $path . '/info.php';
	}	
	
	$c->assign(array(
		'purl'		=> ujn::getCFG('plugins_url'),
		'leftnavs'	=> $left
	));
	return $c;
}